Skip to content

Conversation

@firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

Might make sense to be able to specify the type via a rule file as well. That would also allow to mix and match the engines depending on required performance/features. Or maybe even only allow it via a file so to not add another CLI option and not having to deal with the left-to-right issues.

@firewave
Copy link
Collaborator Author

This will only add the additional engine. I will also do some performance tests.

The follow-up steps are:

  • implement PCRE2 as an additional engine and make it optional via a new build flag
  • make std::regex the default and deprecate HAVE_RULES and PCRE1 so the feature works without any build dependencies
  • remove HAVE_RULES and PCRE1 shortly after (most distros have already dropped the dependency since the library has long been EOL)

@danmar
Copy link
Owner

danmar commented Oct 17, 2025

thanks for working on this. 👍

@firewave
Copy link
Collaborator Author

Might make sense to be able to specify the type via a rule file as well. That would also allow to mix and match the engines depending on required performance/features. Or maybe even only allow it via a file so to not add another CLI option and not having to deal with the left-to-right issues.

@danmar any comment on this?

@firewave
Copy link
Collaborator Author

No comment so I will go with the way to specify the engine via XML only and not providing a CLI option for it.

@firewave firewave force-pushed the regex-std branch 3 times, most recently from d2a9725 to e3ff0a0 Compare November 11, 2025 20:20
@firewave firewave changed the title Regex: added std::regex implementation fixed #14261 - Regex: added std::regex implementation Nov 11, 2025
@firewave
Copy link
Collaborator Author

The follow-up steps are:

I filed some tickets for those:
https://trac.cppcheck.net/ticket/14262
https://trac.cppcheck.net/ticket/14263

@firewave
Copy link
Collaborator Author

The documentation on how to use rules is unfortunately some PDFs hosted at Sourceforge so there is nowhere to add the new field. I filed https://trac.cppcheck.net/ticket/14264 about migrating the documentation.

@firewave firewave changed the title fixed #14261 - Regex: added std::regex implementation fixed #14261 - Regex: added std::regex implementation / added engine to rule XML to specify regex engine Nov 11, 2025
@firewave firewave marked this pull request as ready for review November 11, 2025 20:35
@firewave
Copy link
Collaborator Author

Great - std::regex appears to behave differently in Visual Studio:

D:\a\cppcheck\cppcheck\test\testregex.cpp:181(TestRegExStd::exactmatch): Assertion failed. 
Expected: 
0

Actual: 
2

Why am I not surprised?!

And on macos testrunner is not showing the failed test:

TestVarID::structuredBindings


Testing Complete
Number of tests: 5164
Number of todos: 371
make: *** [test] Error 1
Error: Process completed with exit code 2.

@firewave
Copy link
Collaborator Author

Great - std::regex appears to behave differently in Visual Studio:

Apparently std::regex is partially broken in the current Visual Studio version (not sure if it is what affects the test): https://developercommunity.visualstudio.com/t/std::regex-gives-a-different-result-in-m/10417784

So that partially derails the plan going forward and makes things more awkward. And I have not even profiled it yet...

@sonarqubecloud
Copy link

@firewave
Copy link
Collaborator Author

Coincidentally Visual Studio 2026 was released just a few hours ago and I can confirm that the test passes in it.

@firewave firewave marked this pull request as draft November 11, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants